package com.iplant.pdm.service.po.bop;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.pdm.service.po.mss.MSSBOMItem;

import java.io.Serializable;
import java.util.*;

/**
 * 工艺集工序
 *
 * @author YouWang·Peng
 * 2023-7-26 16:04:18
 */
@DBBasePO(TableName = "fpc_routepartpoint", CheckName = {"Code", "RouteID,RoutePartID,Name"}, CodeAuto = true,
        CodePrefix = "Step-",
        CodeNum = 4,
        Schemas = DBSchemas.PDM)
public class FPCRoutePartPoint extends BasePO implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    @DBCondition
    @DBField
    public String Version = "";

    @DBCondition
    @DBField
    public int RouteID = 0; // 工艺版本ID

    @DBCondition
    @DBField
    public int ProductID = 0;

    @DBJoin(name = "Code", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public String RouteCode = "";

    @DBJoin(name = "Name", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public String RouteName = ""; // 工艺名称

    @DBJoin(name = "Version", tableName = "fpc_route", tableAsName = "route1", Schemas = DBSchemas.PDM,
            MainTableField = "RouteID")
    public String RouteVersion = "";

    @DBCondition
    @DBField
    public int RoutePartID = 0; // 工艺集ID

    /**
     * 标准工艺编号 提供标准工艺知识库
     */
    @DBJoin(name = "PartCode", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String PartCode = "";

    @DBJoin(name = "Code", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartCode = "";

    @DBJoin(name = "Name", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartName = "";

    @DBJoin(name = "Version", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartVersion = "";

    @DBJoin(name = "OrderID", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public int RoutePartOrder = 0;

    @DBJoin(name = "WorkShopID", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public int WorkShopID = 0;
    @DBJoin(name = "WorkAreaID", tableName = "fpc_routepart", tableAsName = "routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public int WorkAreaID = 0;

    @DBField
    public int OrderID = 0; // 循序

    /**
     * 工序类型
     */
    @DBField
    public int PartPointType = 0;


    /**
     * 工序产品类型  1 元件 0 非元件
     */
    @DBField
    @DBCondition
    public int ComponentType = 0;


    /**
     * 工序产出单件的元件数量
     */
    @DBJoin(name = "ComponentNumber", tableName = "fpc_product_com", tableAsName = "fp_c1", Schemas = DBSchemas.PDM,
            ConditionalJoin = "t.ProductID=fp_c1.ProductID and t.ComponentType=fp_c1.TargetComponentType" +
                    " and fp_c1.ComponentType =2 ")
    public int ComponentNumber = 1;

    /**
     * 一个产出需要扫描数量
     */
    @DBField
    public int ScanComponentType = 0;

    @DBJoin(name = "ComponentNumber", tableName = "fpc_product_com", tableAsName = "fp_c2", Schemas = DBSchemas.PDM,
            ConditionalJoin = "t.ProductID=fp_c2.ProductID and t.ScanComponentType=fp_c2.ComponentType" +
                    " and fp_c1.TargetComponentType =t.ComponentType ")
    public int ScanComponentNumber = 1;


    /**
     * 工序ID
     */
    @DBField
    public int PartPointID = 0;

    /**
     * 标准工艺编号 提供标准工艺知识库
     */
    @DBJoin(name = "Code", tableName = "fpc_partpoint", tableAsName = "partpoint1", Schemas = DBSchemas.Basic,
            MainTableField = "PartPointID")
    public String PartPointCode = "";
    /**
     * 工序名称
     */
    @DBJoin(name = "Name", tableName = "fpc_partpoint", tableAsName = "partpoint1", Schemas = DBSchemas.Basic,
            MainTableField = "PartPointID")
    public String PartPointName = "";

    /**
     * 前工艺工序ID
     */
    @DBCondition
    @DBField
    public int PrevPartPointID = 0;// 上工序路线ID
    /**
     * 前工艺工序名称
     */
    @DBJoin(name = "Name", tableName = "fpc_routepartpoint", tableAsName = "routepartpoint1", Schemas = DBSchemas.PDM,
            MainTableField = "PrevPartPointID")
    public String PrevPartPointName = "";

    /**
     * 工序控制（广机）
     */
    @DBField
    public int ChangeControl = 0;

    /**
     * 控制工序集合
     */
    @DBField
    public List<Integer> ControlPartPointID = new ArrayList<Integer>();

    /**
     * 控制工序名称
     */
    @DBJoinMulti(Name = "Name", MainTableField = "ControlPartPointID", TableName = "fpc_partpoint", Schemas =
            DBSchemas.Basic
    )
    public String ControlPartPointName = "";

    /**
     * 工序文件ID集合
     */
    @DBField
    public List<Integer> FileIDList = new ArrayList<>();

    /**
     * 工序文件
     */
    @DBJoinMulti(Name = "FileUrl", MainTableField = "FileIDList", TableName = "sfc_file", Schemas = DBSchemas.MES
    )
    public String PartPointFile = "";

    /**
     * 标准工时
     */
    @DBField
    public Double StandardPeriod = 0.0;

    /**
     * 调整工时 新增字段
     */
    @DBField
    public Double ActualPeriod = 0.0;

    /**
     * 新增字段 满足工艺需求
     */
    @DBField
    public String DefaultOrder = "";

    public int ItemCount = 0;

    /**
     * 后工艺工序集合
     */
    @DBField
    public List<Integer> NextPartPointID = new ArrayList<Integer>();

    public String NextPartPointName = "";

    @DBField
    public Map<String, String> NextPartPointIDMap = new HashMap<String, String>();// 上工段路线ID

    @DBField
    public List<Integer> StationID = new ArrayList<Integer>();
    @DBJoinMulti(Name = "Name", MainTableField = "StationID", TableName = "fmc_station", Schemas = DBSchemas.Basic
    )
    public String StationName = "";
    @DBJoinMulti(Name = "Code", MainTableField = "StationID", TableName = "fmc_station", Schemas = DBSchemas.Basic
    )
    public String StationCode = "";

    public List<FPCStepSOP> StepSOPList = new ArrayList<>();
    public List<FPCRouteStation> RouteStationList = new ArrayList<>();

    public List<MSSBOMItem> BOMItemList = new ArrayList<>();

    @DBField
    public int Period = 0; // 工艺间隔（默认：-1）


    /**
     * 单日最小批量
     */
    @DBField
    public int FQTY = 0;

    @DBField
    public int MaxPeriod = 0;//最大间隔时长

    /**
     * 换产批量
     */
    @DBField
    public double BatchFQTY = 0.0;

    /**
     * 排产间隔
     */
    @DBField
    public int SchedulePeriod = 0;


    /**
     * 是否需要交接
     */
    @DBField
    public int HandoverSemiProduct = 0;

    /**
     * 互检模式  1 下工序互检  0 本工序互检
     */
    @DBField(DefaultValue = "'1'")
    public int MutualModel = 1;

    /**
     * 报工模式  1 手动报工  2 自动报工 3数量报工
     */
    @DBCondition
    @DBField
    public int ReportMode = 0;


    /**
     * 自动报工数量
     */
    @DBCondition
    @DBField
    public int ReportFQTY = 1;

    /**
     * 是否需要生成码
     */
    @DBCondition
    @DBField
    public int IsGenerateCode = 0;

    /**
     * 是否强制做专检
     */
    @DBCondition
    @DBField
    public int IsSpecialCheck = 0;

    /**
     * 是否为关键工艺
     */
    @DBCondition
    @DBField
    public int KeyProcess = 0;

    @JsonProperty("SchedulePeriod")
    public int getSchedulePeriod() {
        return SchedulePeriod;
    }

    public void setSchedulePeriod(int schedulePeriod) {
        SchedulePeriod = schedulePeriod;
    }

    @JsonProperty("Version")
    public String getVersion() {
        return Version;
    }

    public void setVersion(String version) {
        Version = version;
    }

    @JsonProperty("RouteID")
    public int getRouteID() {
        return RouteID;
    }

    public void setRouteID(int routeID) {
        RouteID = routeID;
    }

    @JsonProperty("RouteCode")
    public String getRouteCode() {
        return RouteCode;
    }

    public void setRouteCode(String routeCode) {
        RouteCode = routeCode;
    }

    @JsonProperty("RouteName")
    public String getRouteName() {
        return RouteName;
    }

    public void setRouteName(String routeName) {
        RouteName = routeName;
    }

    @JsonProperty("RouteVersion")
    public String getRouteVersion() {
        return RouteVersion;
    }

    public void setRouteVersion(String routeVersion) {
        RouteVersion = routeVersion;
    }

    @JsonProperty("RoutePartID")
    public int getRoutePartID() {
        return RoutePartID;
    }

    public void setRoutePartID(int routePartID) {
        RoutePartID = routePartID;
    }

    @JsonProperty("PartCode")
    public String getPartCode() {
        return PartCode;
    }

    public void setPartCode(String partCode) {
        PartCode = partCode;
    }

    @JsonProperty("RoutePartCode")
    public String getRoutePartCode() {
        return RoutePartCode;
    }

    public void setRoutePartCode(String routePartCode) {
        RoutePartCode = routePartCode;
    }

    @JsonProperty("RoutePartName")
    public String getRoutePartName() {
        return RoutePartName;
    }

    public void setRoutePartName(String routePartName) {
        RoutePartName = routePartName;
    }

    @JsonProperty("RoutePartVersion")
    public String getRoutePartVersion() {
        return RoutePartVersion;
    }

    public void setRoutePartVersion(String routePartVersion) {
        RoutePartVersion = routePartVersion;
    }

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("PartPointType")
    public int getPartPointType() {
        return PartPointType;
    }

    public void setPartPointType(int partPointType) {
        PartPointType = partPointType;
    }

    @JsonProperty("PartPointID")
    public int getPartPointID() {
        return PartPointID;
    }

    public void setPartPointID(int partPointID) {
        PartPointID = partPointID;
    }

    @JsonProperty("PartPointCode")
    public String getPartPointCode() {
        return PartPointCode;
    }

    public void setPartPointCode(String partPointCode) {
        PartPointCode = partPointCode;
    }

    @JsonProperty("PartPointName")
    public String getPartPointName() {
        return PartPointName;
    }

    public void setPartPointName(String partPointName) {
        PartPointName = partPointName;
    }

    @JsonProperty("PrevPartPointID")
    public int getPrevPartPointID() {
        return PrevPartPointID;
    }

    public void setPrevPartPointID(int prevPartPointID) {
        PrevPartPointID = prevPartPointID;
    }

    @JsonProperty("PrevPartPointName")
    public String getPrevPartPointName() {
        return PrevPartPointName;
    }

    public void setPrevPartPointName(String prevPartPointName) {
        PrevPartPointName = prevPartPointName;
    }

    @JsonProperty("ChangeControl")
    public int getChangeControl() {
        return ChangeControl;
    }

    public void setChangeControl(int changeControl) {
        ChangeControl = changeControl;
    }

    @JsonProperty("ControlPartPointID")
    public List<Integer> getControlPartPointID() {
        return ControlPartPointID;
    }

    public void setControlPartPointID(List<Integer> controlPartPointID) {
        ControlPartPointID = controlPartPointID;
    }

    @JsonProperty("ControlPartPointName")
    public String getControlPartPointName() {
        return ControlPartPointName;
    }

    public void setControlPartPointName(String controlPartPointName) {
        ControlPartPointName = controlPartPointName;
    }

    @JsonProperty("PartPointFile")
    public String getPartPointFile() {
        return PartPointFile;
    }

    public void setPartPointFile(String partPointFile) {
        PartPointFile = partPointFile;
    }

    @JsonProperty("StandardPeriod")
    public Double getStandardPeriod() {
        return StandardPeriod;
    }

    public void setStandardPeriod(Double standardPeriod) {
        StandardPeriod = standardPeriod;
    }

    @JsonProperty("ActualPeriod")
    public Double getActualPeriod() {
        return ActualPeriod;
    }

    public void setActualPeriod(Double actualPeriod) {
        ActualPeriod = actualPeriod;
    }

    @JsonProperty("DefaultOrder")
    public String getDefaultOrder() {
        return DefaultOrder;
    }

    public void setDefaultOrder(String defaultOrder) {
        DefaultOrder = defaultOrder;
    }

    @JsonProperty("ItemCount")
    public int getItemCount() {
        return ItemCount;
    }

    public void setItemCount(int itemCount) {
        ItemCount = itemCount;
    }

    @JsonProperty("NextPartPointID")
    public List<Integer> getNextPartPointID() {
        return NextPartPointID;
    }

    public void setNextPartPointID(List<Integer> nextPartPointID) {
        NextPartPointID = nextPartPointID;
    }

    @JsonProperty("NextPartPointName")
    public String getNextPartPointName() {
        return NextPartPointName;
    }

    public void setNextPartPointName(String nextPartPointName) {
        NextPartPointName = nextPartPointName;
    }

    @JsonProperty("NextPartPointIDMap")
    public Map<String, String> getNextPartPointIDMap() {
        return NextPartPointIDMap;
    }

    public void setNextPartPointIDMap(Map<String, String> nextPartPointIDMap) {
        NextPartPointIDMap = nextPartPointIDMap;
    }

    @JsonProperty("StationID")
    public List<Integer> getStationID() {
        return StationID;
    }

    public void setStationID(List<Integer> stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("StepSOPList")
    public List<FPCStepSOP> getStepSOPList() {
        return StepSOPList;
    }

    public void setStepSOPList(List<FPCStepSOP> stepSOPList) {
        StepSOPList = stepSOPList;
    }

    @JsonProperty("RouteStationList")
    public List<FPCRouteStation> getRouteStationList() {
        return RouteStationList;
    }

    public void setRouteStationList(List<FPCRouteStation> routeStationList) {
        RouteStationList = routeStationList;
    }

    @JsonProperty("Period")
    public int getPeriod() {
        return Period;
    }

    public void setPeriod(int period) {
        Period = period;
    }

    @JsonProperty("MaxPeriod")
    public int getMaxPeriod() {
        return MaxPeriod;
    }

    public void setMaxPeriod(int maxPeriod) {
        MaxPeriod = maxPeriod;
    }

    @JsonProperty("BOMItemList")
    public List<MSSBOMItem> getBOMItemList() {
        return BOMItemList;
    }

    public void setBOMItemList(List<MSSBOMItem> BOMItemList) {
        this.BOMItemList = BOMItemList;
    }

    @JsonProperty("BatchFQTY")
    public double getBatchFQTY() {
        return BatchFQTY;
    }

    public void setBatchFQTY(double batchFQTY) {
        BatchFQTY = batchFQTY;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("FQTY")
    public int getFQTY() {
        return FQTY;
    }

    public void setFQTY(int FQTY) {
        this.FQTY = FQTY;
    }

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("HandoverSemiProduct")
    public int getHandoverSemiProduct() {
        return HandoverSemiProduct;
    }

    public void setHandoverSemiProduct(int handoverSemiProduct) {
        HandoverSemiProduct = handoverSemiProduct;
    }

    @JsonProperty("ReportMode")
    public int getReportMode() {
        return ReportMode;
    }

    public void setReportMode(int reportMode) {
        ReportMode = reportMode;
    }

    @JsonProperty("ReportFQTY")
    public int getReportFQTY() {
        return ReportFQTY;
    }

    public void setReportFQTY(int reportFQTY) {
        ReportFQTY = reportFQTY;
    }

    @JsonProperty("MutualModel")
    public int getMutualModel() {
        return MutualModel;
    }

    public void setMutualModel(int mutualModel) {
        MutualModel = mutualModel;
    }

    @JsonProperty("IsGenerateCode")
    public int getIsGenerateCode() {
        return IsGenerateCode;
    }

    public void setIsGenerateCode(int isGenerateCode) {
        IsGenerateCode = isGenerateCode;
    }

    @JsonProperty("IsSpecialCheck")
    public int getIsSpecialCheck() {
        return IsSpecialCheck;
    }

    public void setIsSpecialCheck(int isSpecialCheck) {
        IsSpecialCheck = isSpecialCheck;
    }

    @JsonProperty("ScanComponentType")
    public int getScanComponentType() {
        return ScanComponentType;
    }

    public void setScanComponentType(int scanComponentType) {
        ScanComponentType = scanComponentType;
    }

    @JsonProperty("ScanComponentNumber")
    public int getScanComponentNumber() {
        return ScanComponentNumber;
    }

    public void setScanComponentNumber(int scanComponentNumber) {
        ScanComponentNumber = scanComponentNumber;
    }

    @JsonProperty("ComponentNumber")
    public int getComponentNumber() {
        return ComponentNumber;
    }

    public void setComponentNumber(int componentNumber) {
        ComponentNumber = componentNumber;
    }

    @JsonProperty("RoutePartOrder")
    public int getRoutePartOrder() {
        return RoutePartOrder;
    }

    public void setRoutePartOrder(int routePartOrder) {
        RoutePartOrder = routePartOrder;
    }

    @JsonProperty("KeyProcess")
    public int getKeyProcess() {
        return KeyProcess;
    }

    public void setKeyProcess(int keyProcess) {
        KeyProcess = keyProcess;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("FileIDList")
    public List<Integer> getFileIDList() {
        return FileIDList;
    }

    public void setFileIDList(List<Integer> fileIDList) {
        FileIDList = fileIDList;
    }
}
